unit untFichaFinanceira;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, untAbsConsulta, Vcl.ActnList, Vcl.Menus,
  Vcl.ImgList, Vcl.StdCtrls, Vcl.Grids, Vcl.DBGrids, Vcl.ExtCtrls, Vcl.ComCtrls,
  Vcl.ToolWin, untDTMPrincipal, Data.DB, Data.Win.ADODB,
  untFichaFinanceiraEdicao;

type
  TfrmFichaFinanceira = class(TfrmAbsConsulta)
    qryRecebido: TADOQuery;
    qryRecebidoNOME: TStringField;
    qryRecebidoDT_PGTO: TDateTimeField;
    qryRecebidoVALOR: TFloatField;
    qryRecebidoREGIONAL: TStringField;
    qryRecebidoBANCO: TStringField;
    dtsRecebido: TDataSource;
    qryRecebidoIDUSUARIO_EXCLUSAO: TIntegerField;
    qryRecebidoDT_EXCLUSAO: TDateTimeField;
    qryRecebidoEXCLUIDO: TStringField;
    qryRecebidoID: TAutoIncField;
    qryRecebidoID_COLABORADOR: TAutoIncField;
    procedure qryRecebidoDT_PGTOGetText(Sender: TField; var Text: string;
      DisplayText: Boolean);
    procedure acIncluirExecute(Sender: TObject);
    procedure acAlterarExecute(Sender: TObject);
  private
    { Private declarations }
    FID_Colaborador : Integer;
  public
    { Public declarations }
    constructor Create(AOwner : TComponent; ID : Integer); Overload;
  end;

var
  frmFichaFinanceira: TfrmFichaFinanceira;

implementation

{$R *.dfm}

procedure TfrmFichaFinanceira.acAlterarExecute(Sender: TObject);
var
  frm : TfrmFichaFinanceiraEdicao;
begin
  try
    frm := TfrmFichaFinanceiraEdicao.Create(self,qryRecebidoID.AsInteger);
    frm.ID_Colaborador := qryRecebidoID_COLABORADOR.AsInteger;
    frm.ShowModal();
  finally
    FreeAndNil(frm);
  end;
  AtualizaCds();
end;

procedure TfrmFichaFinanceira.acIncluirExecute(Sender: TObject);
var
  frm : TfrmFichaFinanceiraEdicao;
begin
  try
    frm := TfrmFichaFinanceiraEdicao.Create(self);
    frm.ID_Colaborador := FID_Colaborador;
    frm.ShowModal();
  finally
    FreeAndNil(frm);
  end;
  AtualizaCds();
end;

constructor TfrmFichaFinanceira.Create(AOwner: TComponent; ID: Integer);
begin
  inherited
  Create(AOwner);
  cdsAtual.Close();
  cdsAtual.Parameters.ParamByName('ID').Value := ID;
  cdsAtual.Open();
  FID_Colaborador := ID;
end;

procedure TfrmFichaFinanceira.qryRecebidoDT_PGTOGetText(Sender: TField;
  var Text: string; DisplayText: Boolean);
begin
  if not Sender.IsNull then
    Text := FormatDateTime('DD/MM/YYYY',Sender.AsFloat);
end;

end.
